import request from '@/utils/request'

// 登录并返回用户信息
export const userLoginService = ({ username, password }) => {
  return request({
    url: '/login',
    method: 'post',
    data: {
      username: username,
      password: password,
    },
  })
}

// 返回所有员工信息
export const userGetAllUsers = () => {
  return request({
    url: '/user/getAllUsers',
    method: 'get',
  })
}

// 查询用户名
export const userQueryUserLikeByName = (name) => {
  return request({
    url: '/user/queryUserLikeByName',
    params: {
      name: name,
    },
  })
}

// 更新管理员信息
export const userUpdateUserById = ({ id, name, username, phone, sex, password }) => {
  return request({
    url: '/user/updateUserById',
    method: 'patch',
    data: {
      id,
      name,
      username,
      phone,
      sex,
      password,
    },
  })
}
// 更新管理员状态
export const userUpdateStatusById = ({ id, status }) => {
  return request({
    url: '/user/updateUserStatusById',
    method: 'patch',
    data: {
      id,
      status,
    },
  })
}

// 添加管理员
export const userAddUser = ({ username, name, password, phone, sex }) => {
  return request({
    url: '/user/addUser',
    method: 'post',
    data: {
      username,
      name,
      password,
      phone,
      sex,
    },
  })
}
// 根据id查询密码
export const userQueryPasswordById = () => {
  return request({
    url: '/user/getUserById',
  })
}
// 根据id更新密码
export const userUpdateUserPasswordById = ({ password }) => {
  return request({
    method: 'patch',
    url: '/user/updateUserPasswordById',
    data: {
      password,
    },
  })
}
